package com.firewolf.hibernate.extend.subclass;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

/**
 * 父类
 * @author liuxing
 *
 */
@Entity
//@Inheritance：指明是哪种继承，SINGLE_TABLE表示生成一张表，
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
//@DiscriminatorColumn：用来区分是哪一个类的字段信息
@DiscriminatorColumn(name="type",length=10)
//@DiscriminatorValue：标志某一个类的标志
@DiscriminatorValue("PERSON")
@Table(name="person")
public class Person {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer personId;
	@Column
	private String name;
	@Column
	private Integer age;
	public Integer getPersonId() {
		return personId;
	}
	public void setPersonId(Integer personId) {
		this.personId = personId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
}
